const app = getApp()
Page({


  data: {
    catelist: ["男装", "女装", "零食", "家电", "床上用品", "家具"],
    bannerlist: [{
      url: "../../images/banner1.jpg"
    }, {
      url: "../../images/banner2.jpg"
    }, {
      url: "../../images/banner3.jpg"
    }],
    latitude:"",
    longitude:""

  },
  danmulist: [{
      text: "网院",
      color: "#ff000",
      time: 1
    },
    {
      text: "电大",
      color: "#E64#69",
      time: 30

    }
  ],
  onLoad: function (options) {
    var id = options.id;
    console.log(id);


  },
  checkboxchange: function (e) {
    var then = this;
    var likestr = "";
    for (let index = 0; index < e.detail.value; index++) {
      likestr = likestr + e.detail.value[index];

    }
    console.log(likestr)
    then.setData({
      likes: e.detail.value[0]
    })
    console.log(e)
    console.log(e.detail.value[0])
  },
  bindViewTap() {
    wx.navigateTo({
      url: '../logs/logs'
    })
  },


  gotoBooklist() {
    wx.navigateTo({
      url: '../../pages/booklist/booklist',
    })
  },
  gotoBookpage() {
    wx.navigateTo({
      url: '../../pages/bookpage/bookpage',
    })
  },
  gotoRegister() {
    wx.navigateTo({
      url: '../../pages/register/register',
    })
  },
  onLoad() {},
  //     if (wx.getUserProfile) {
  //       this.setData({
  //         canIUseGetUserProfile: true
  //       })
  //     }
  //   }
  // })
  saveUserInfo: function () {
    var data = {
      "name": "自己的名字",
      "student_id": "201965110453"
    }
    wx.setStorageSync('userinfo', data)
    wx.setStorage({
      data: "studentinfo",
      key: {
        "sex": 男,
        "age": 21
      }
    })
  },
  getUserInfo: function () {
    //同步获取
    var studentinfo = wx.getStorageInfoSync('studentinfo');
    console.log(studentinfo);
    //异步获取
    wx.getStorage({
      key: "userinfo",
      success(res) {
        console.log(res);
      }
    })
    wx.getStorageInfo({
      success: (option) => {
        console.log(option)
      },
    })

  },
  removeUserInfo: function () {
    //异步移除
    wx.removeStorage({
      key: 'userinfo',
    })
    wx.removeStorageSync('studentinfo');

  },
  getLocal: function () {
    var then=this;
    wx.getLocation({
      success(res) {
        type:"gjc02";
        console.log(res)
       then.setData({
         latitude:res.latitude,
         longitude:res.longitude
         
       })
      }
    })

  },
  openMap: function () {
    var then=this;
    wx.openLocation({
 
      latitude:then.data.latitude,
    longitude:then.data.longitude,
    name:"湖南开发大学1104",
         address:"湖南省长沙市天心区秦园路168号1104"
  })

  },
  selectLocal: function () {
    var then =this;
    wx.chooseLocation({
      latitude: then.data.latitude,
      longitude:then.data.longitude

    })

  },
  call:function(){
    wx.makePhoneCall({
      phoneNumber: '15115573293',
    })
  },
  scanCode:function(){
    wx.scanCode({
      onlyFromCamera: true,
      success(res){
        console.log(res)
      }
    })
  }
})